home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 31
/
Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso
/
Opus5.5
/
ARexx.lha
/
ARexx
/
ADPro_BatchConvert.dopus5
next >
Wrap
Text File
|
1996-06-13
|
10KB
|
294 lines
/* ADPro_BatchConvert for Directory Opus 5.5 and ADPro 2.5.x
by Leo 'Nudel' Davidson for Gods'Gift Utilities
email: leo.davidson@keble.oxford.ac.uk www: http://users.ox.ac.uk/~kebl0364
$VER: ADPro_BatchConvert.dopus5 1.3 (13.6.96)
------------------------------------------------------------------------
Call as:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[ARexx] DOpus5:ARexx/ADPro_BatchConvert.dopus5 {Qp} {Ql} {d}
Flags: Rescan Destination
------------------------------------------------------------------------
You are asked for a render mode and images will be scaled so that they
fill the screen (without changing their aspect). You are given the option
of doubling the X and Y resolution of image for rendering to modes with
different aspect to the picture. Finally you are given a choice of
dither types. Then all pictures selected will be processed and the results
saved in the destination directory.
Filenames with "JPG", "JPEG", or "GIF" at the end will have their
extensions removed. The screen-depth is appended to the end of the
filename, also.
Currently, if ADPro already running, does not restore settings after
exiting. If this is important let me know.
------------------------------------------------------------------------
The path to ADPro: (Normally "ADPro:ADPro")
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
ADPro = "ADPro:ADPro"
/*===================================================================================*/
options results
options failat 99
parse arg DOpusPort source_handle.0 dest_path.0 .
DOpusPort = Strip(DOpusPort,"B",'" ')
source_handle.0 = Strip(source_handle.0,"B",'" ')
dest_path.0 = Strip(dest_path.0,"B",'" ')
If DOpusPort="" THEN Do
Say "Not correctly called from Directory Opus 5!"
Say "Load this ARexx script into an editor for more info."
EXIT
END
If ~Show("P",DOpusPort) Then Do
Say DOpusPort "is not a valid port."
EXIT
End
Address value DOpusPort
/*===================================================================================*/
/* Thanks Edmund */
dopus version
If ( result='RESULT' | translate(result,'.',' ') < 5.1218 ) then do
dopus request '"This script requires DOpus v5.5 or greater." OK'
EXIT
end
/*===================================================================================*/
Quit_After = "NO"
If ~Show("P",'ADPro') Then Do
Call Pragma(Stack,20000)
Address Command "Run >NIL:" ADPro "NS MINIMIZED"
Address Command "WaitForPort" 'ADPro'
Quit_After = "YES"
If ~Show("P",'ADPro') then do
lister request source_handle.0 '"Error loading ADPro!'|| '0a'x ||'Check its command-path in the ARexx script itself." OK'
EXIT
END
END
/*===================================================================================*/
BadNumber = 0
failplural = "s"
lister set source_handle.0 busy 1
lister query source_handle.0 numselentries /* Get info about selected */
Lister_NumSelEnt = RESULT /* entries & path to them */
lister query source_handle.0 path
Lister_Path = Strip(RESULT,"B",'"')
lister set source_handle.0 newprogress abort bar info file name title
lister set source_handle.0 newprogress title "Converting pictures... (0 fails)"
lister set source_handle.0 newprogress info "Setting up..."
lister set source_handle.0 newprogress bar Lister_NumSelEnt 0
/*===================================================================================*/
/* Could save the current settings for restoration later, but I don't
really care about them. */
Address "ADPro"
OBTAIN_ADPRO /* You're mine! */
/*-----------------------------------------------------------------------------------**
Get Screen Mode
**-----------------------------------------------------------------------------------*/
ADPRO_TO_FRONT
GET_SCREEN_MODE "'Select render mode'" "Amiga" 167972 1440 564 "HAM8"
parse var adpro_result mode.type mode.id MaxWidth MaxHeight mode.depth
mode.depth = Strip(mode.depth)
SET_RENDER_MODE mode.type mode.id MaxWidth MaxHeight mode.depth
/*-----------------------------------------------------------------------------------**
Get Dither type
**-----------------------------------------------------------------------------------*/
GETLIST DITHERS
dither_list = ADPRO_RESULT
allents = dither_list
entries=0
do while allents~=''
entries=entries+1
parse var allents '"' spam '"' allents
end
ADPRO_TO_FRONT
LISTVIEW '"Select Dither Mode:"' entries ITEMS dither_list
If RC > 1 Then call END_ABORT_EARLY
parse var ADPRO_RESULT '"' dither_mode '"' spam
If dither_mode = "Off" then
dither_set = 0
Else do
spam = word(dither_mode,words(dither_mode))
parse var spam "(" dither_set ")"
end
dither dither_set
/*-----------------------------------------------------------------------------------**
Get Aspect Correction
**-----------------------------------------------------------------------------------*/
ADPRO_TO_FRONT
OKAYN "Scale" '"Double horizontal resolution?"' "Yes|No"
If RC = 1 Then WidthScale = 2
Else WidthScale = 1
OKAYN "Scale" '"Double vertical resolution?"' "Yes|No"
If RC = 1 Then HeightScale = 2
Else HeightScale = 1
/*-----------------------------------------------------------------------------------**
Handle the rest.
**-----------------------------------------------------------------------------------*/
PWidth "ENHANCED" /* Enhanced palette accuracy */
LFormat "UNIVERSAL" /* Load anything you can! */
SFormat "IFF" /* Save as IFF format (See save part, too) */
RMode "LOCKED" /* Lock the screen mode */
RDepth "LOCKED" /* Lock the screen depth */
/*===================================================================================*/
Address value DOpusPort
dopus front
/*===================================================================================*/
BarTotal = 3 * Lister_NumSelEnt
Do i=1 to Lister_NumSelEnt
lister query source_handle.0 firstsel
Temp_Name = Strip(RESULT,"B",'"')
Temp_Path = Lister_Path || Temp_Name
lister set source_handle.0 newprogress name Temp_Name
lister set source_handle.0 newprogress bar Lister_NumSelEnt i
lister query source_handle.0 abort
If RESULT=1 Then Call END_ABORT
lister set source_handle.0 newprogress file BarTotal (3 * i - 3)
lister set source_handle.0 newprogress info "Loading..."
Address "ADPro" LOAD '"'Temp_Path'"'
If RC~=0 Then Do
BadNumber = BadNumber + 1
If BadNumber = 1 Then failplural = ""
Else If BadNumber = 2 Then failplural = "s"
BadList.BadNumber = Temp_Name
lister set source_handle.0 newprogress title "Converting pictures... ("BadNumber "fail"failplural")"
End
Else Do
Address "ADPro" XSIZE;ImageWidth = ADPRO_RESULT
Address "ADPro" YSIZE;ImageHeight = ADPRO_RESULT
DesiredHeight = HeightScale * ImageHeight
DesiredWidth = WidthScale * ImageWidth
/*-----------------------------------------------------------------------------------*/
lister query source_handle.0 abort
If RESULT=1 Then Call END_ABORT
lister set source_handle.0 newprogress file BarTotal (3 * i - 2)
lister set source_handle.0 newprogress info "Scaling..."
/* If it's smaller than the max area, enlarge it */
IF DesiredHeight < MaxHeight THEN DO
Scale = MaxHeight / DesiredHeight
DesiredHeight = DesiredHeight * Scale
DesiredWidth = DesiredWidth * Scale
END
IF DesiredWidth < MaxWidth THEN DO
Scale = MaxWidth / DesiredWidth
DesiredHeight = DesiredHeight * Scale
DesiredWidth = DesiredWidth * Scale
END
/* Make sure it isn't bigger than the max-area */
IF DesiredHeight > MaxHeight THEN DO
Scale = MaxHeight / DesiredHeight
DesiredHeight = DesiredHeight * Scale
DesiredWidth = DesiredWidth * Scale
END
IF DesiredWidth > MaxWidth THEN DO
Scale = MaxWidth / DesiredWidth
DesiredHeight = DesiredHeight * Scale
DesiredWidth = DesiredWidth * Scale
END
Address "ADPro" ABS_SCALE DesiredWidth DesiredHeight
/*-----------------------------------------------------------------------------------*/
lister query source_handle.0 abort
If RESULT=1 Then Call END_ABORT
lister set source_handle.0 newprogress file BarTotal (3 * i - 1)
lister set source_ha